package com.dm.shop.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.activerecord.Model;

import java.time.LocalDateTime;
import java.io.Serializable;
import java.util.Date;
import java.util.List;

import com.dm.shop.vo.ProductVO;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import lombok.experimental.Accessors;

/**
 * <p>
 * 
 * </p>
 *
 * @author MyBatisPlusGenerater-Saiya Wang
 * @since 2021-07-20
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value="Product对象", description="")
@AllArgsConstructor
@NoArgsConstructor
public class Product implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 商品编号
     */
    @ApiModelProperty(value = "商品编号")
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    /**
     * 商品名称
     */
    private String name;

    /**
     * 小标题
     */
    private String store;

    /**
     * 原价
     */
    private Float originalPrice;

    /**
     * 促销价
     */
    private Float promotePrice;

    /**
     * 库存
     */
    private Integer stock;

    /**
     * 类别编号
     */
    private Integer cid;

    /**
     * 收藏量
     */
    private Integer collectNum;

    /**
     * 月销量
     */
    private Integer saleNum;

    /**
     * 创建时间
     */
    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @TableField(fill = FieldFill.INSERT)
    private Date createTime;

    /**
     * 修改时间
     */
    @ApiModelProperty(value = "修改时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Date updateTime;

    /**
     * 逻辑删除，0为未删除，1为删除
     */
    @TableLogic
    private Integer deleted;

    public Product(ProductVO productVO){
        this.store = productVO.getShopName();
        this.cid=productVO.getCid();
        this.promotePrice=productVO.getPromotePrice();
        this.originalPrice=productVO.getPrice();
        this.name=productVO.getIntro();
        this.stock=productVO.getStock();
        this.saleNum=productVO.getSaleNum();
        this.collectNum=productVO.getCollectNum();
    }

}
